<?php
/**
 * Copyright (c) 2006-2008, Julien PORTALIER
 * http://featherphp.googlecode.com/
 * 
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 */
class String extends ActiveRecord
{
	protected $_has_many = array('Message');
	
	/**
	 * Returns the list of contexts.
	 * 
	 * @return Array
	 */
	function & get_contexts()
	{
		$options = array(
			'process' => DBO::PROCESS_LIST,
			'extend'  => false
		);
		return $this->find_all('DISTINCT context', &$options);
	}
	
	/**
	 * 
	 * @return Array
	 * @param $ctx String
	 */
	function & get_strings($ctx, $locale)
	{
		$strings = $this->find_all_by_context($ctx);
		foreach($strings as $str)
		{
			$options = array(
				'conditions' => array(
					'string_id' => $str->id,
					'locale'    => $locale
				)
			);
			$str->messages = $this->Message->find_all('msgstr', &$options);
		}
		return $strings;
	}
}
?>